﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/UserMaster.master"
    Inherits="System.Web.Mvc.ViewPage<Eacademy.Domain.Models.AdminMentorsViewModel>" %>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {

            $("#dialog-alert").dialog({
                resizable: false,
                height: 120,
                modal: true,
                position: 'fixed',
                autoOpen: false,
                draggable: false,
                buttons: {
                    "OK": function () {
                        $(this).dialog("close");
                    }
                }
            });


            $("#change-password-button").live("click", function (event) {
                event.preventDefault();
                var $link = $(this);
                $("#dialog-password").dialog({
                    resizable: false,
                    height: 140,
                    width: 330,
                    modal: true,
                    draggable: false,
                    buttons: {
                        "Continue": function () {
                            $(this).dialog("close");
                            $.blockUI({ css: {
                                border: 'none',
                                padding: '15px',
                                message: 'changing password...',
                                backgroundColor: '#000',
                                '-webkit-border-radius': '10px',
                                '-moz-border-radius': '10px',
                                opacity: .5,
                                color: '#fff',
                                'font-size': '8px',
                                'font-family': 'verdana'
                            }
                            });

                            $.ajax({
                                type: "POST",
                                url: $("#dialog-password form").attr("action"),
                                data: $("#dialog-password form").serialize(),
                                success: function (result) {
                                    $.unblockUI({
                                        onUnblock: function () {
                                            clearFormElements($("#dialog-password form"));
                                            $("#dialog-alert p").html(result.responseText);
                                            $("#dialog-alert").dialog("open");
                                        }
                                    });
                                },
                                error: function (request, status, errorThrown) {
                                    $.unblockUI({
                                        onUnblock: function () {
                                            clearFormElements($("#dialog-password form"));
                                            $("#dialog-alert p").html(request.responseText);
                                            $("#dialog-alert").dialog("open");
                                        }
                                    });
                                }
                            });

                        },
                        Cancel: function () {
                            clearFormElements($(this));
                            $(this).dialog("close");
                        }
                    }
                });
            })

            var auth = "<% = Request.Cookies[FormsAuthentication.FormsCookieName]==null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value %>";
            var ss = "<%= Session.SessionID %>;"
            $('#file-upload').uploadify({
                uploader: "/content/uploadify.swf",
                script: "/mentor/profile/uploadimage/",
                cancelImg: "/content/images/cancel.png",
                buttonText: "Change Picture",
                auto: true,
                queueID: 'uploadifyQueue',
                queueSizeLimit: 100,
                simUploadLimit: 1,
                removeCompleted: false,
                scriptData: { authtoken: auth, si: ss },
                fileDesc: 'Image (*.jpg;*.jpeg;*.gif;*.png)',
                fileExt: '*.jpg;*.jpeg;*.png;*.gif',
                multi: false,
                onSelect: function (event, ID, fileObj) {
                    $('.preview > table').hide();
                    $('.preview').addClass('loading');
                },
                onComplete: function (event, ID, fileObj, response, data) {
                    var thumb = $('#thumb');
                    var dataResponse = $.parseJSON(response);
                    $('.preview > table').show();
                    $('.preview').removeClass('loading');
                    thumb.attr('src', dataResponse.url);
                    $("#file-name").val(dataResponse.filename);
                },
                onError: function (a, b, c, d) {
                    if (d.status == 404)
                        alert("Could not find upload script. Use a path relative to: ");
                    else if (d.type === "HTTP")
                        alert("error " + d.type + ": " + d.status);
                    else if (d.type === "File Size")
                        alert(c.name + " " + d.type + " Limit: " + Math.round(d.sizeLimit / 1024) + "KB");
                    else
                        alert("error " + d.type + ": " + d.text);
                }
            });
        });
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Edit Profile
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Edit Profile</h2>
    <% using (Html.BeginForm("Edit", "Profile", FormMethod.Post, new { autocomplete = "off" }))
       {%>
    <div class="forms-elements">
        <div class="form-wrapper">
            <div class="form-label">
                Image
            </div>
            <div class="form-element">
                <div class="preview">
                    <table style="margin: 0pt auto;" cellpadding="0" cellspacing="0">
                        <tbody>
                            <tr>
                                <td style="height: 100px;">
                                    <img src="<%= Model.ThumbImagePathName %>" id="thumb" />
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
                <div class="wrap">
                    <label>
                        Upload a picture for mentor</label>
                    <input id="file-upload" name="file_upload" type="file" />
                    <input id="file-name" type="hidden" name="filename" value="<%= Model.ImageName %>" />
                </div>
            </div>
            <div class="form-error form-error-100">
            </div>
        </div>
        <div class="form-wrapper">
            <div class="form-label">
                <%: Html.LabelFor(model => model.FirstName)%>
            </div>
            <div class="form-element">
                <div class="textbox-xmedium-form">
                    <%: Html.TextBoxFor(model => model.FirstName, new { @class = "textbox-xmedium-field" })%>
                </div>
            </div>
            <div class="form-error form-error-150">
                <%: Html.ValidationMessageFor(model => model.FirstName)%>
            </div>
        </div>
        <div class="form-wrapper">
            <div class="form-label">
                <%: Html.LabelFor(model => model.MiddleName)%>
            </div>
            <div class="form-element">
                <div class="textbox-xmedium-form">
                    <%: Html.TextBoxFor(model => model.MiddleName, new { @class = "textbox-xmedium-field" })%>
                </div>
            </div>
            <div class="form-error form-error-150">
                <%: Html.ValidationMessageFor(model => model.MiddleName)%>
            </div>
        </div>
        <div class="form-wrapper">
            <div class="form-label">
                <%: Html.LabelFor(model => model.LastName)%>
            </div>
            <div class="form-element">
                <div class="textbox-xmedium-form">
                    <%: Html.TextBoxFor(model => model.LastName, new { @class = "textbox-xmedium-field" })%>
                </div>
            </div>
            <div class="form-error form-error-150">
                <%: Html.ValidationMessageFor(model => model.LastName)%>
            </div>
        </div>
        <div class="form-wrapper">
            <div class="form-label">
                <%: Html.LabelFor(model => model.PrimaryEmail)%>
            </div>
            <div class="form-element">
                <div class="textbox-xmedium-form">
                    <%: Html.TextBoxFor(model => model.PrimaryEmail, new { @class = "textbox-xmedium-field" })%>
                </div>
            </div>
            <div class="form-error form-error-150">
                <%: Html.ValidationMessageFor(model => model.PrimaryEmail)%>
            </div>
        </div>
        <div class="form-wrapper">
            <div class="form-label">
                <%: Html.LabelFor(model => model.SecondaryEmail)%>
            </div>
            <div class="form-element">
                <div class="textbox-xmedium-form">
                    <%: Html.TextBoxFor(model => model.SecondaryEmail, new { @class = "textbox-xmedium-field" })%>
                </div>
            </div>
            <div class="form-error form-error-150">
                <%: Html.ValidationMessageFor(model => model.SecondaryEmail)%>
            </div>
        </div>
        <br />
        <div class="form-wrapper">
            <div class="form-label">
                <%: Html.LabelFor(model => model.Username)%>
            </div>
            <div class="form-element">
                <div class="textbox-form">
                    <%: Html.TextBoxFor(model => model.Username, new { @class = "textbox-field" })%>
                </div>
            </div>
            <div class="form-error form-error-150">
                <%: Html.ValidationMessageFor(model => model.Username)%>
            </div>
        </div>
        <div class="form-wrapper">
            <div class="form-label">
            </div>
            <div class="form-element">
                <a href="#" id="change-password-button">Change Password</a>
            </div>
        </div>
        <div class="form-wrapper">
            <div class="form-label">
                <%: Html.LabelFor(model => model.EmployeeNumber)%>
            </div>
            <div class="form-element">
                <div class="textbox-form">
                    <%: Html.TextBoxFor(model => model.EmployeeNumber, new { @class = "textbox-field" })%>
                </div>
            </div>
            <div class="form-error form-error-150">
                <%: Html.ValidationMessageFor(model => model.EmployeeNumber)%>
            </div>
        </div>
        <div class="form-wrapper">
            <div class="form-label">
            </div>
            <div class="form-element">
                <input type="submit" value="Save" class="button-style" />
                <input type="button" value="Cancel" onclick="window.open('/mentor','_self');"
                    class="button-style" />
            </div>
        </div>
        <div class="form-wrapper">
            <%:Html.HiddenFor(model => model.MentorId) %>
        </div>
    </div>
    <% } %>
    <div id="dialog-alert" class="dialog" title="" style="display: none;">
        <p>
            Password successfully changed</p>
    </div>
    <div id="dialog-password" class="dialog" title="Change password" style="display: none;">
        <form method="post" action="/mentor/profile/changepassword">
        <div class="details">
            <div class="field">
                New Password</div>
            <input type="text" id="password" name="password" />
        </div>
        <div class="horizontal-loader">
        </div>
        </form>
    </div>
</asp:Content>
